package android.os;

import android.content.Context;
import android.util.Log;

import java.lang.reflect.Method;

public final class WtWdPowerManager
{
    private static final String TAG = "WtWd_Power";
    private final String mPackageName;
    private  IWtWdPowerService mService=null;

    public WtWdPowerManager(Context context)
    {
        this.mPackageName = context.getPackageName();
        try{
            Object object = new Object();
            Method getService = Class.forName("android.os.ServiceManager").getMethod("getService", String.class);
            Object obj = getService.invoke(object, new Object[]{new String("wtwd_power")});
//System.out.println(obj.toString());
            mService = IWtWdPowerService.Stub.asInterface((IBinder)obj);
        }catch(Exception ex){
//ignored
        }

        if (this.mService == null)
            Log.w("WtWd_Power", "WtWdPowerManager: no WtWdPowerManager ir service.");
    }

    public int getWtWdPowerState(int cmd)
    {
        try {
            return this.mService.getWtWdPowerState(cmd);
        }
        catch (RemoteException localRemoteException) {
        }
        return 0;
    }
    public int setPower(int val) {
        try {
            return this.mService.setPower(val);
        } catch (RemoteException localRemoteException) {
        }
        return 0;
    }
}